package cn.liyicun.cp.cpweb.service;

import cn.liyicun.cp.cpweb.entity.MoneyLog;
import cn.liyicun.cp.cpweb.entity.MoneyLogExample;
import cn.liyicun.cp.cpweb.mapper.MoneyLogMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MoneyLogService {


    @Autowired
    private MoneyLogMapper moneyLogMapper;

    public PageInfo<MoneyLog> search(Long uid, int currentPage, int pageSize) {
        MoneyLogExample example = new MoneyLogExample();
        if (uid != null && uid > 0) {
            example.createCriteria().andUidEqualTo(uid);
        }
        example.setOrderByClause("id desc");
        PageHelper.startPage(currentPage, pageSize);
        List<MoneyLog> docs = moneyLogMapper.selectByExample(example);
        PageInfo<MoneyLog> pageInfo = new PageInfo<>(docs);
        return pageInfo;
    }

}
